﻿//This file has been served as replacement for the real service client during development
Type.registerNamespace("dnneurope.portalgroups");

dnneurope.portalgroups.ServiceClient = function (moduleId) {
    var self = this;
    self.getModel = function () {
        console.log("get Model from Fake Service");
        var df = new $.Deferred();
        df.resolve(new FakeModel());
        return df.promise();
    };
    self.save = function (group) {
        console.log("save Group with Fake Service");
        console.log(group);
        var df = new $.Deferred();
        df.resolve(-1);
        return df.promise();
    };
    self.delete = function (groupId) {
        console.log("delete Group by id with Fake Service");
        var df = new $.Deferred();
        df.resolve();
        return df.promise();
    };
};

var FakeModel = function () {
    return {
        PortalGroups: [{ PortalGroupId: 1, MasterPortal: { PortalId: 1, PortalName: "PortalOne" }, PortalGroupName: "Group1", AuthenticationDomain: "Domain1", Portals: [] },
                     {
                         PortalGroupId: 2, MasterPortal: { PortalId: 2, PortalName: "PortalTwo" }, PortalGroupName: "Group2", AuthenticationDomain: "Domain2", Portals:
                             [{ PortalId: 5, PortalName: "PortalFive" }, { PortalId: 6, PortalName: "PortalSix" }]
                     }],
        AvailablePortals: [{ PortalId: 3, PortalName: "PortalThree" }, { PortalId: 1, PortalName: "PortalFour" }]
    };
}